package org.example.dao.ordergoods;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.example.entity.OrderGoods;

import java.util.List;

@Mapper
public interface OrderGoodsMapper {

    @Insert("insert into order_goods(order_id, goods_id, goods_image, goods_name," +
            " goods_unit, price, num, specs_name) " +
            "VALUES(#{orderId},#{goodsId},#{goodsImage},#{goodsName},#{goodsUnit}," +
            "#{price},#{num},#{specsName}) ")
    boolean addOrderGoods(OrderGoods orderGoods);

    @Select("select * from order_goods where order_id = #{orderId}")
    List<OrderGoods> getOrderGoodsByOrderId(Integer orderId);

    @Delete("delete from order_goods where order_id=#{orderId}")
    boolean deleteOrderByOrderId(Integer orderId);
}
